<?php use_helper('Number') ?>
<div class="center_title">
    <?php echo __('receipt list', array()) ?>
</div>

<?php if (!$pager->getNbResults()): ?>
<div>
    <?php echo __('No results') ?>.
</div>
<?php else: ?>

<div class="center_text">
    <div class="text_item">

        <table width="100%" cellpadding="2" cellspacing="1" class="cart">
            <tr>
                <th>ID</th>
                <th><?php echo __('status') ?></th>
                <th><?php echo __('User info') ?></th>
                <th><?php echo __('created at') ?></th>
                <th><?php echo __('completed at') ?></th>
                <th><?php echo __('shipping price') ?></th>
                <th><?php echo __('items qnt') ?></th>
                <th><?php echo __('total price') ?></th>
                <th><?php echo __('actions') ?></th>
            </tr>
        <?php $i = 1; foreach ($pager->getResults() as $receipt): $odd = fmod(++$i, 2) ?>
            <tr class="sf_admin_row_<?php echo $odd ?>">
                <td align="right"><?php echo link_to(
                                  $receipt->getId()
                                  , 'cart/preview?id='.$receipt->getId()
                              ) ?></td>
                <td align="center"><?php echo image_tag(
                                    'status_' . $receipt->getStatusId() . '.png'
                                    , array(
                                        'border' => '0'
                                        , 'alt' => __(MyConstants::getStatusName($receipt->getStatusId()))
                                        , 'title' => __(MyConstants::getStatusName($receipt->getStatusId()))
                                    )
                                ) ?></td>
                
                <td align="center"><?php echo link_to(
                                            image_tag(
                                                'userinfo.png'
                                                , array(
                                                    'alt' => __('User info')
                                                    , 'title' => __('User info')
                                                )
                                            )
                                            , 'cart/userinfo?cart=' . $receipt->getId()
                                            , array('popup' => array('popupWindow'
                                                                    , 'width=310,height=400,left=320,top=0')))?></td>
                <td align="center"><?php echo $receipt->getCreatedAt() ?></td>
                <td align="center"><?php echo $receipt->getCompletedAt() ?></td>
                <td align="center"><?php echo format_currency($receipt->getShippingPriceMinor($sf_user->getAttribute('currency', 'EUR'))
                    											, $sf_user->getAttribute('currency', 'EUR')) ?></td>
                <td align="center"><?php echo $receipt->getItemsQnt() ?></td>
                <td align="right"><?php echo format_currency($receipt->getPriceByCurrencyCode($sf_user->getAttribute('currency', 'EUR'))
                							+$receipt->getShippingPriceMinor($sf_user->getAttribute('currency', 'EUR'))
                							, $sf_user->getAttribute('currency', 'EUR')) ?></td>
                <td align="center"><?php echo link_to(
                                    __('Perform order')
                                    , 'cart/perform?id=' . $receipt->getId()
                                    , 'confirm=' . __('Are you sure?')
                                ) ?><br />
                    <?php echo link_to(__('View order')
                                    , 'cart/preview?id='.$receipt->getId())?>
                </td>

            </tr>
        <?php endforeach; ?>
            <tr>
                <th colspan="100%">&nbsp;</th>
            </tr>
        </table>

        <?php if ($pager->haveToPaginate()): ?>
            <div class="paging">
                <div class="paging_link">
                    <?php echo link_to(
                            '&laquo;'
                            , 'cart/orders?page='.$pager->getFirstPage()
                        ) ?>
                </div>
                <div class="paging_link">
                    <?php echo link_to(
                            '&lsaquo;'
                            , 'cart/orders?page='.$pager->getPreviousPage()
                        ) ?>
                </div>
                    <?php $links = $pager->getLinks(); foreach ($links as $page): ?>
                    <?php echo ($page == $pager->getPage()) ? '<div class="paging_current">' . $page . '</div>' : '<div class="paging_link">' . link_to($page, 'cart/orders?page='.$page) . '</div>' ?>
                    <?php if ($page != $pager->getCurrentMaxLink()): ?>
                    <?php endif; ?>
                    <?php endforeach; ?>
                <div class="paging_link">
                    <?php echo link_to(
                                '&rsaquo;'
                                , 'cart/orders?page='.$pager->getNextPage()
                            ) ?>
                </div>
                <div class="paging_link">
                    <?php echo link_to(
                                '&raquo;'
                                , 'cart/orders?page='.$pager->getLastPage()
                            ) ?>
                </div>
            </div>
        <?php endif ?>
</div>
<?php endif; /* end elsif receipts */ ?>

</div>